package com.springcloudserver.config;

import com.springcloudserver.common.AjaxResult;
import com.springcloudserver.service.FeiginService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @description:
 * @author: chenzuolin
 * @time: 2021/3/21 17:59
 */
@Component
public class FeignServiceFallFactoryConfig implements FallbackFactory<FeiginService> {
    @Override
    public FeiginService create(Throwable throwable) {
        return new FeiginService() {
            @Override
            public AjaxResult hi() {
                return AjaxResult.error("fallbackFactory调用失败！！！" + throwable.getMessage());
            }

            @Override
            public AjaxResult findUserInfoById(String id) {
                return AjaxResult.error("fallbackFactory调用失败！！！" + throwable.getMessage());
            }

            @Override
            public AjaxResult findAllUserInfo() {
                return AjaxResult.error("fallbackFactory调用失败！！！" + throwable.getMessage());
            }
        };
    }
}
